#ifndef GT_ENTRY_H
#define GT_ENTRY_H

#include "isearch.h"
#include <cstddef>

#define container_of(ptr, type, member)                                        \
  ((type *)((char *)(ptr) - offsetof(type, member)))

enum entry_type_t { FILE_ENTRY, LINE_ENTRY };

struct entry_t;
struct entry_vtable {
  void (*display)(entry_t *, search_t *, int, int);
  int (*is_selectable)(entry_t *);
  void (*free)(entry_t *);
  void *(*get_type)(entry_t *, entry_type_t);
};

struct entry_t {
  entry_vtable *vtable;
  entry_t *next;
  char data[];
};

void display_entry(entry_t *entry, search_t *search, int y,
                   int is_cursor_on_entry);

void free_entry(entry_t *entry);

int is_entry_selectable(entry_t *entry);

void *get_type(entry_t *entry, entry_type_t type);

#endif // header file protect
       // ok